/**
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "pico/stdlib.h"
#include "cmsis_os.h"

extern int application_entry(void *arg);

void task_test(void *pdata){
    application_entry(NULL);
    while (true);
}
osThreadDef(task_test, osPriorityNormal, 1, 256 * 4);

void SysTick_Handler(void){ 
    if(tos_knl_is_running()){
        tos_knl_irq_enter();
        tos_tick_handler();
        tos_knl_irq_leave();
    }
}

int main() {
    stdio_init_all();
    uart_init(uart0, 115200);
    gpio_set_function(0, GPIO_FUNC_UART);  // TX
    gpio_set_function(1, GPIO_FUNC_UART);  // RX
    stdio_uart_init_full(uart0, 115200, 0, 1);

    osKernelInitialize(); //TOS Tiny kernel initialize
    osThreadCreate(osThread(task_test), NULL);
    osKernelStart();//Start TOS Tiny

    while (true);
}
